home *** CD-ROM | disk | FTP | other *** search
- class CCVAxisAlignedBox extends CCollisionVolume
- {
- var m_width;
- var m_height;
- var m_body;
- function CCVAxisAlignedBox(body, width, height)
- {
- super(body);
- this.m_width = width;
- this.m_height = height;
- if(body)
- {
- if(!width)
- {
- this.m_width = body._width;
- }
- if(!height)
- {
- this.m_height = body._height;
- }
- }
- }
- function get _halfWidth()
- {
- return this.m_width * 0.5;
- }
- function get _halfHeight()
- {
- return this.m_height * 0.5;
- }
- function get _boundingRadius()
- {
- return Math.max(this._halfHeight,this._halfWidth);
- }
- function get _center()
- {
- return this.m_body._location;
- }
- function get _topLeftCorner()
- {
- return new Vector2D(this.m_body._x - this.m_width * 0.5,this.m_body._y - this.m_height * 0.5);
- }
- function get _bottomRightCorner()
- {
- return new Vector2D(this.m_body._x + this.m_width * 0.5,this.m_body._y + this.m_height * 0.5);
- }
- function get _left()
- {
- return this.m_body._x - this.m_width * 0.5;
- }
- function get _right()
- {
- return this.m_body._x + this.m_width * 0.5;
- }
- function get _top()
- {
- return this.m_body._y - this.m_height * 0.5;
- }
- function get _bottom()
- {
- return this.m_body._y + this.m_height * 0.5;
- }
- function set _topLeftCorner(corner)
- {
- this.m_width = (this.m_body._x - corner._x) * 2;
- this.m_height = (this.m_body._y - corner._y) * 2;
- }
- function set _bottomRightCorner(corner)
- {
- this.m_width = (corner._x - this.m_body._x) * 2;
- this.m_height = (corner._y - this.m_body._y) * 2;
- }
- function set _left(value)
- {
- this.m_width = (this.m_body._x - value) * 2;
- }
- function set _right(value)
- {
- this.m_width = (value - this.m_body._x) * 2;
- }
- function set _top(value)
- {
- this.m_height = (this.m_body._y - value) * 2;
- }
- function set _bottom(value)
- {
- this.m_height = (value - this.m_body._y) * 2;
- }
- }
-